<template>
  <div class="leftBottom">
    <div class="title">
      <span class="word">场景需求:节能、舒适</span>
      <div class="block">
        <el-date-picker
          v-model="value1"
          type="daterange"
          range-separator="To"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :disabled-date="(time) => time.getTime() > Date.now()"
          size="small"
          @change="handelChangeTime"
          value-format="YYYY-MM-DD"
        />
      </div>
    </div>
    <div class="line"></div>
    <div class="tablebox">
      <el-table
        :data="
          JSON.parse(props.demand).slice(
            (currentPage - 1) * pagesize,
            currentPage * pagesize
          )
        "
        stripe
        style="width: 100%; min-height: 240px"
      >
        <el-table-column type="index" label="序号" width="50" />
        <el-table-column prop="time" label="日期" width="100" />
        <el-table-column prop="need" label="需求内容" />
        <el-table-column prop="level" label="级别" width="50" />
      </el-table>
    </div>
    <div class="page">
      <div class="example-pagination-block">
        <el-pagination
          layout="prev,pager,next"
          :page-size="pagesize"
          :total="JSON.parse(props.demand).length"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          position="center"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, defineProps, defineEmits } from "vue";

var currentPage = ref(1);
var pagesize = ref(6);
const value1 = ref("");
const props = defineProps({
  demand: String,
});
const emit = defineEmits(["dateChange"]);

//日期选择
const handelChangeTime = (val) => {
  emit("dateChange", val);
};
function handleCurrentChange(Page) {
  //页码更改方法
  currentPage.value = Page;
}
</script>

<style scoped lang="less">
.leftBottom {
  width: 100%;
  height: 410px;
  border-style: none;
  border-color: unset;
  box-shadow: rgb(77 98 165 / 10%) 0px 5px 20px 0px;
  border-radius: 8px;
  font-size: 14px;
  padding: 1px;
  line-height: 20px;
  font-weight: normal;
  font-style: normal;
  background-color: white;

  .title {
    padding: 0.313rem 0.5rem;
    display: flex;
    position: relative;
    .word {
      font-family: SourceHanSansSC;
      font-weight: 550;
      font-size: 18px;
      color: rgb(77, 98, 165);
      font-style: normal;
      letter-spacing: 2px;
      line-height: 28px;
      text-decoration: none;
      margin-bottom: 15px;
      margin-top: 15px;
    }
  }
  .line {
    border-bottom: 2px rgba(77, 98, 165, 0.2) solid;
  }
  .tablebox {
    padding: 10px 10px;
  }
  .page {
    padding: 13px 0;
    display: flex;
    justify-content: center;
  }
  .block {
    // width: 200px;
    margin-left: 20px;
    margin-top: 19px;
  }
}
</style>
<style>
.example-pagination-block + .example-pagination-block {
  margin-top: 10px;
}
.example-pagination-block .example-demonstration {
  margin-bottom: 12px;
}
.el-table tr {
  background-color: rgb(246, 250, 255);
}

.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}
.el-date-editor--daterange.el-input__inner {
  width: 230px;
}
.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
.el-table td.el-table__cell,
.el-table th.el-table__cell.is-leaf {
  border-bottom: none;
}
</style>
